package com.example.admin.goodnews.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.Window;
import android.view.animation.AlphaAnimation;
import android.widget.Button;
import android.widget.ImageView;

import com.example.admin.goodnews.R;

/**
 * 引导页面
 * Created by admin on 2016/9/27.
 */

public class GuideActivity extends AppCompatActivity {
    private ImageView iv_guide_find;
    private ImageView iv_guide_goodnews;
    private Button btn_guide_start;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_guide);
        initView();
        initEvent();
        SetAnimation();//  设置动画
        if (getSupportActionBar() != null){
            getSupportActionBar().hide();
        }
    }

    private void initView() {
        iv_guide_find = (ImageView) findViewById(R.id.iv_guide_find);
        iv_guide_goodnews = (ImageView) findViewById(R.id.iv_guide_goodnews);
        btn_guide_start = (Button) findViewById(R.id.btn_guide_start);
    }

    private void initEvent() {
        btn_guide_start.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(GuideActivity.this, MainActivity.class);
                startActivity(intent);
                finish();
            }
        });
    }

    private void SetAnimation() {
        AlphaAnimation alphaAnimation = new AlphaAnimation(0.1f, 1.0f);
        alphaAnimation.setDuration(2000);
        alphaAnimation.setRepeatCount(0);
        alphaAnimation.setFillAfter(true);
        iv_guide_find.setAnimation(alphaAnimation);
        iv_guide_goodnews.setAnimation(alphaAnimation);
    }

}
